from PIL import Image
import os

def imgPreProcess(image: str, percentage: float = 0.5) -> str:
    # try:
    with Image.open(os.path.join("img", image)) as img:
        width, height = img.size
        new_width = int(width * percentage)
        new_height = int(height * percentage)
        img = img.resize((new_width, new_height), Image.LANCZOS)
        img.save(os.path.join("img", image.replace(".jpg", ".jpeg")), 'JPEG')
    # except Exception as e:
    #     print(f"imgPreProcess Error: {e}")
            